/*
 * @Copyright: 2017 www.yyfax.com Inc. All rights reserved.
 */
package com.yyfax.pay.order.model.to;

import org.apache.commons.lang3.StringUtils;

import com.yyfax.framework.exception.YYException;
import com.yyfax.framework.yyfax.enums.RspCodeEnum;
import com.yyfax.pay.common.enums.PaymentEnum;
import com.yyfax.pay.common.model.to.YYPayParams;

/**
 * 用户鉴权信息查询
 * 
 * @author buyi
 * @date 2017-04-18 19:38:58
 * @since v1.0.0
 */
@SuppressWarnings("serial")
public class RemoveUserPaymentParams extends YYPayParams {
	private String serverIp;
	private String merchantCode; // 商户编号
	private String userId; // 商户用户ID
	private String paymentCode;
	private String cardNo;

	public String getServerIp() {
		return serverIp;
	}

	public void setServerIp(String serverIp) {
		this.serverIp = serverIp;
	}

	public String getMerchantCode() {
		return merchantCode;
	}

	public void setMerchantCode(String merchantCode) {
		this.merchantCode = merchantCode;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPaymentCode() {
		return paymentCode;
	}

	public void setPaymentCode(String paymentCode) {
		this.paymentCode = paymentCode;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	@Override
	public boolean validate() throws Exception {

		if (StringUtils.isBlank(this.serverIp)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'serverIp'不能为空");
		}

		if (StringUtils.isBlank(this.merchantCode)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'merchantCode'不能为空");
		}

		if (StringUtils.isBlank(this.userId)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'userId'不能为空");
		}

		if (StringUtils.isBlank(this.paymentCode) || PaymentEnum.fromValue(this.paymentCode) == null) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'paymentCode'不能为空/paymentCode非法");
		}

		if (StringUtils.isBlank(this.cardNo)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'cardNo'不能为空");
		}

		return true;
	}

	@Override
	public String[] signFields() {
		return new String[] { "serverIp", "merchantCode", "userId", "paymentCode", "cardNo" };
	}
}
